<?php

namespace app\admin\model;

use think\Model;


class Invoice extends Model
{

    

    

    // 表名
    protected $name = 'invoice';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'invoice_type_text'
    ];
    protected $json = ['order_id'];

    protected $type = [
        'create_invoice_time' => 'timestamp'
    ];

    
    public function getInvoiceTypeList()
    {
        return ['normal' => __('Normal'), 'special' => __('Special')];
    }


    public function getInvoiceTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['invoice_type']) ? $data['invoice_type'] : '');
        $list = $this->getInvoiceTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
